package Test;

import java.util.ArrayList;
import java.util.List;

public class Test01 {
	
	public static void main(String[] args) {
		List<Integer> likeValues = new ArrayList<>();
		likeValues.add(1);
		likeValues.add(2);
		likeValues.add(3);
		likeValues.add(3);
		likeValues.add(5);
		
		List<SearchParam> searchParams = new ArrayList<>();
		SearchParam searchParam1 = new SearchParam(1,2,1);
		SearchParam searchParam2= new SearchParam(2,4,5);
		SearchParam searchParam3 = new SearchParam(3,5,3);
		searchParams.add(searchParam1);
		searchParams.add(searchParam2);
		searchParams.add(searchParam3);
		List<Integer> answers = getAnswer(5, likeValues, 3, searchParams);
		System.out.println(answers);
	}
    public static List<Integer> getAnswer(int n,List<Integer> likeValues,int q, List<SearchParam> searchParams ){
    	List<Integer> answer = new ArrayList<>();
    	
    	for(SearchParam searchParam : searchParams) {
    		int count = 0;
    		for(int i= searchParam.getL() - 1;i < searchParam.getR() - 1; i++) {
	    		if (likeValues.get(i) == searchParam.getK()){
	    			count++;
	    		}
    		}
    		answer.add(count);
    	}
    	
    	
    	return answer;
    }
}

class SearchParam{
	int l;
	int r;
	int k;
	
	
	
	public SearchParam(int l, int r, int k) {
		super();
		this.l = l;
		this.r = r;
		this.k = k;
	}

	public int getL() {
		return l;
	}
	
	public void setL(int l) {
		this.l = l;
	}
	
	
	public int getR() {
		return r;
	}
	
	public void setR(int r) {
		this.r = r;
	}
	
	public int getK() {
		return k;
	}
	
	public void setK(int k) {
		this.k = k;
	}
	
}
